﻿<?php include("template/baglanti.php"); include ("upload.php"); include("template/header.php"); ?>
<link rel="stylesheet" type="text/css" href="css/main.css" />
       
        <?php
		
	$id = intval($_GET['id']);
	$ctID = intval($_GET['ctID']);




$ok = "";
$save = $_POST['save'];

if ($save) {



//Konu Ekleme Alanı



$Phctid = $_POST['ctID'];
$Phid = $_POST['id'];
$Phname = $_POST['Phname'];
$Phinfo = $_POST['Phinfo'];
$Phinfocn = $_POST['Phinfocn'];
$Phshow= $_POST['Phshow'];

$dosyasmall = $_FILES['dosyasmall']; if ( $dosyasmall['name'] != '') { $photosmall = upload_pic($dosyasmall);	}			
$dosya = $_FILES['dosya']; if ( $dosya['name'] != '') { $photo = upload_pic($dosya); }


@mysql_query("insert into photogaleri
(`categori_id`, `PdID`, `Phname`,  `Phinfo`,  `Phinfocn`, `Phsphoto` , `Phphoto` ,  `Phshow` )
values ('$ctID', '$id', '$Phname',  '$Phinfo', '$Phinfocn', '$photosmall', '$photo' , '$Phshow' )");

echo mysql_error();
$ok = "done";
}

if(!$ok) {


?>



<div class="clear"> </div>

<div class="wrapper">

<div class="menu radius flt">
<?php include("./template/menu.php") ?>
</div>



<div class="wrapperInside radius flt">


<div class="wrapperInsideCapture">Add Products</div>

<div class="wpForm">

<form class="validate" name="form1" method="post" id="save" enctype="multipart/form-data" >








<div class="wpFormLabelBox">
<div class="wpFormLabel"> Products Name </div>
<div class="wpFormText radius"> <input name="Phname" type="text"></div>
</div>



<div class="wpFormLabelBox">
<div class="wpFormLabel "> Products Information</div>
<div class="wpFormText" style="display:block; height:100%;">
<textarea name="Phinfo" id="textarea" cols="45"rows="5" /  class="mceEditor"  ></textarea>
</div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormLabel ">Products (Chinese)Information</div>
<div class="wpFormText" style="display:block; height:100%;">
<textarea name="Phinfocn" id="textarea" cols="45"rows="5" /  class="mceEditor"  ></textarea>
</div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormLabel"> Small Photo (250 x 250px)</div>

<input type="file" name="dosyasmall"  />
</div>

<div class="wpFormLabelBox">
<div class="wpFormLabel"> Big Size Photo (1000px x 1000px)</div>

<input type="file" name="dosya" />

</div>







<div class="wpFormLabelBox">
<div class="wpFormLabel">Show Page</div>
<div class="wpFormCheck">
<input id="radio1" type="radio" name="Phshow" value="1" > <label> Yes </label>
<input id="radio1" type="radio" name="Phshow" value="0" style="margin-left:24px;"> <label> No</label>
</div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormButton"><input type="submit" name="save" id="save" value="Add" class="radius"></div>
</div>


</form>



</div>

<?php } if ($ok == "done"): ?>
<div class="welldone"><img src="images/ok.jpg" width="300" height="300"><br>
Your process well done !<br><a href="productsGalery.php">:: OK :: </a> </div>
<?php endif; ?>
</div>
</div>


<?php include("template/footer.php") ?>

<?php 

function upload_pic($file)
{
	
	
	$upload = new upload($file);
	
	$new_name = substr(md5(time()),0,6).substr(md5(rand(0,100000)),0,6);
	
	
	#big
	$upload->file_new_name_body     = $new_name;
	$upload->process('../upload/products');
	if($upload->processed){
		$upload->clean();
		return $new_name.'.jpg';
	}
	
	echo 'Hata:'.$upload->error.'-'.$upload->file_dst_path;exit;

}
?>

